/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package metricmaster.gui.projecttab;

import java.awt.Color;
import java.awt.Dimension;
import java.util.ArrayList;

import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.border.TitledBorder;

import metricmaster.gui.AppData;
import metricmaster.model.Activity;

/**
 *
 * @author markblanda
 */
public class ActivitiesPanel extends JPanel {
    private JTable activitiesTable;
    private ActivitiesTableModel tableModel;
    private JScrollPane scrollPane;
    
    private ArrayList<Activity> activities;

    public ActivitiesPanel() {
        setupComponents();
        this.add(scrollPane);
        this.setBorder(new TitledBorder("Project Activities"));
    }

    private void setupComponents() {
    	activities = AppData.getInstance().getProject().getProjectActivities();
        tableModel = new ActivitiesTableModel(activities);
        activitiesTable = new JTable(tableModel);
        activitiesTable.setPreferredScrollableViewportSize(new Dimension(450, 480));
        activitiesTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
        activitiesTable.setShowGrid(true);
        activitiesTable.setGridColor(Color.BLACK);
        scrollPane = new JScrollPane(activitiesTable);
    }

    /**
     * @return the tableModel
     */
    public ActivitiesTableModel getTableModel() {
        return tableModel;
    }

    /**
     * @param tableModel the tableModel to set
     */
    public void setTableModel(ActivitiesTableModel tableModel) {
        this.tableModel = tableModel;
    }
}
